# 待处理请求
from api_setting import *
from dim_api_auto_test.DimAPI.core.request_client import RestClient
from dim_api_auto_test.DimAPI.search import Search
from tools.database import MySQLClient


class PurchaseApplyWaitList(RestClient):
    def __init__(self, **kwargs):
        super(PurchaseApplyWaitList, self).__init__(**kwargs)
        self.search = Search()
        self.mysql = MySQLClient.setup()

    def close_pc_apply_detail(self):
        """
        关闭申购明细
        :return:
        """
        url = CLOSE_PC_APPLY_URL
        # 查询申购状态为 已提交待采购，询价进度为 未活跃 的申购明细，并获取第1个申购记录的id
        order_id = self.mysql.select(SQL001)[0]["id"]
        params = {"ids": order_id, "closedMessage": "测试采购关闭"}
        r = self.get(url=url, params=params)
        return r.content


if __name__ == "__main__":
    test = PurchaseApplyWaitList()
    res = test.close_pc_apply_detail()
    print(res)
